package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderControllerOrderController {
    @Autowired
    private OrderService orderService;

    //用户下单
    /*Request URL: http://localhost:8081/order/submit
Request Method: POST*/
    @PostMapping("/order/submit")
    public ResultInfo orderSubmit(@RequestBody Order order) {
        //调用service生成订单
        orderService.save(order);
        //返回成功
        return ResultInfo.success(null);
    }
//H5历史订单查询.
    @GetMapping("/order/userPage")
    public ResultInfo findPage(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize
    ) {
        Page<Order>page =orderService.findByPage(pageNum, pageSize);
        return ResultInfo.success(page);
    }


}






























